package com.idm.tacacs.transaction;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.idm.tacacs.utils.TacacsException;
import com.idm.tacacs.utils.TacascsUtil;

public class TacacsDao {

	/**
	 * Method : createConnection()
	 *
	 * Method create connection specific to MSSQL based on the Provided 
	 * DataSource Name that is provided as arguement.
	 *
	 * @param String connectionType
	 * @return Connection
	 * @exception TacacsException
	 */

	public static void  UpdateTransaction()throws Exception
	{
		
		
		Connection objConnection= null;
		ResultSet objResultSet  = null;
		CallableStatement  objStatement  = null;	
		String strMethodeName = null;
		//String pass=null;
		String statuscode=null;
		try
		{
			strMethodeName="UpdateTransaction";
			objConnection =TacascsUtil.openConnection();
			objStatement = objConnection.prepareCall("{ call METAImage..p_UpdateTACACSTransaction (?,?,?,?,?,?,?,?,?,?)}");
			// p_UpdateTACACSTransaction "TACAS9","INSERT","User","CG_Z020","2016-10-23 20:44:11","ChangePassword","699","PMO","890"
			objStatement.setString(1,"TACAS90");
			objStatement.setString(2,"INSERT");
			objStatement.setString(3,"User");
			objStatement.setString(4,"CG_Z020");
			objStatement.setString(5,"2016-10-23 20:44:11");
			objStatement.setString(6,"ChangePassword");
			objStatement.setString(7,"699");
			objStatement.setString(8,"PMO");
			objStatement.setString(9,"890");
			objStatement.setString(10,"890");
			objResultSet = objStatement.executeQuery();
			/*
			while (objResultSet.next())
				
			{
				statuscode=objResultSet.getString("status_code");
				pass=objResultSet.getString("pass");
				System.out.println("pass :"+pass);
			}
			*/
			
		}catch(SQLException sqlException){
			throw sqlException;
		}
		catch (Exception objException)
		{
			throw objException;
		}
		finally
		{
			TacascsUtil.closeConnection(objConnection,objStatement,objResultSet);
		}
		
		//return pass;
	}

	public static void main(String[] args) {
		System.out.println("Started ");
		try {
			UpdateTransaction();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
